#ifndef EVENTHANDLING_H_INCLUDED
#define EVENTHANDLING_H_INCLUDED

#include "Slot.h"
#include <map>
#include <string>
#include <my/Config.h>

namespace my {

    /**
    * @class EventHandling
    * @brief Pure Virtual class that provide a simple Signal/Slot system.\n
    *       A Signal is a string and a Slot is a function, connected to each other
    */
    class MYAPI EventHandling
    {
        public:
            /**
            * @brief Default constructor, does nothing
            */
            EventHandling();

            /**
            * @brief Virtual default destructor
            */
            virtual ~EventHandling();

            /**
            * @brief Connect a signal to a slot. When this signal is emitted with emit(std::string signal) the slot is called. Only one slot per signal is admitted
            * @param signal The signal, under std::string form
            * @param function The function to call when the signal is emitted. A slot is a function like void(void)
            */
            void connect(const std::string& signal, my::slot function);

            /**
            * @brief Emit a signal, the associated Slot will be called
            * @param signal The signal to emit, under std::string form
            */
            void emit(const std::string& signal);

            /**
            * @brief Disconnect a signal from a slot.
            * @param signal The signal to remove
            */
            void disconnect(const std::string& signal);

            /**
            * @brief Will remove all signals
            */
            void clear();

        protected:
            std::multimap<std::string, my::slot> _table;
    };

}

#endif // EVENTHANDLING_H_INCLUDED
